package com.b511.swpu.cementbackend.dto.output;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Collection;
import java.util.HashSet;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class CompanyOutputDto {
    private String label;
    private Collection<CompanyOutputDto> children;

    public CompanyOutputDto(String label) {
        this.label = label;
    }

    public void add(CompanyOutputDto c){
        if (this.children==null)
            this.children=new HashSet<>();
        children.add(c);
    }

    @Override
    public int hashCode() {
        return label.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        CompanyOutputDto companyOutputDto = (CompanyOutputDto)obj;
        return this.label.equals(companyOutputDto.label);
    }
}
